package com.lagou.task18;

public class ThreadPriorityTest extends Thread {
    @Override
    public void run() {
        System.out.println("子线程的优先级= " + getPriority());
        //优先级高的线程不一定先执行
        for (int i = 0; i <20 ; i++) {
            System.out.println("子线程的优先级i= " + i);
        }
    }

    public static void main(String[] args) {
        ThreadPriorityTest tp1 = new ThreadPriorityTest();
        //设置子线程优先级
        tp1.setPriority(Thread.MAX_PRIORITY);
        tp1.start();

        System.out.println("主线成的优先级= " + Thread.currentThread().getPriority());
        for (int i = 0; i <20 ; i++) {
            System.out.println("主线成的优先级= " + i);
        }
    }
}
